package front

import (
	request "hft/Http/Models/request/front"
	frontServe "hft/Http/Services/front"
	services "hft/Http/Services/front"
	utils "hft/Http/Utils"
	"strconv"

	"github.com/gin-gonic/gin"
)

type Arc struct{}

func (*Arc) GetArc(c *gin.Context) {

	var city, _ = strconv.Atoi(c.Request.Header.Get("sid"))

	var paginate request.ArcPage

	c.ShouldBind(&paginate)

	data, err := services.ArcService.GetArc(&paginate, city)

	if err != nil {
		utils.FailWithMessage(err.Error(), c)
		return
	}

	utils.OkWithData(data, c)

}

func (*Arc) GetArcInfo(c *gin.Context) {
	id, _ := strconv.Atoi(c.DefaultQuery("id", "0"))

	data, err := frontServe.ArcService.GetArcInfo(id)
	if err != nil {
		utils.FailWithMessage(err.Error(), c)
		return
	}
	utils.OkWithData(data, c)
}

var ArcController = new(Arc)
